/**
 * @author Steven Hobson-Campbell
 * @file main.cpp
 * @date 5/07/12
 */

#include <iostream>
#include <cstdlib>
#include <GL/glfw.h>

//Prototypes
void init();
void keyCallback(int key, int state);

//Globals
bool running_g = true;

int main(int argc, char **argv) {
    //Initialise GLFW
    glfwInit();
    
    //Open a window
    if(!glfwOpenWindow(800, 600, 8, 8, 8, 0, 24, 0, GLFW_WINDOW)) {
	std::cout << "Couldn't open GLFW window" << std::endl;
	glfwTerminate();
	exit(1);
    }
    
    //Register GLFW callbacks
    glfwSetKeyCallback(keyCallback);
    
    //Initialise OpenGL
    init();
    
    //Main loop
    double lastFrameTime = 0;
    while(running_g) {
	
	if((glfwGetTime() - lastFrameTime) > 1.0/200) {
	    lastFrameTime = glfwGetTime();
	    glfwSwapBuffers();
	}
    }
    
    //Cleanup
    glfwTerminate();
    
    return 0;
}

void init() {
    
}

void keyCallback(int key, int state) {
    if(key == GLFW_KEY_ESC) {
	running_g = false;
    }
}